home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / demos / contempo / microhel / resmod.bas < prev    next >
Encoding:
BASIC Source File  |  1994-10-06  |  2.8 KB  |  82 lines

  1. DefInt A-Z  'always a good idea (not necessary if you use Option Explicit)
  2. '--------------------------
  3. ' System information type .
  4. ' for 'About' box         .
  5. ' Requires Windows 3.1 or .
  6. ' Tools.dll               .
  7. '--------------------------
  8.  
  9. ' Constants for GetWinFlags
  10.  Global Const WF_CPU286 = &H2
  11.  Global Const WF_CPU386 = &H4
  12.  Global Const WF_CPU486 = &H8
  13.  Global Const WF_80x87 = &H400
  14.  Global Const WF_STANDARD = &H10
  15.  Global Const WF_ENHANCED = &H20
  16.  
  17. Type SYSHEAPINFO
  18.     dwSize As Long
  19.     wUserFreePercent As Integer
  20.     wGDIFreePercent As Integer
  21.     hUserSegment As Integer
  22.     hGDISegment As Integer
  23. End Type
  24.  
  25. Declare Function GetVersion Lib "Kernel" () As Integer
  26. Declare Function GetWinFlags Lib "Kernel" () As Long
  27. Declare Function GetFreeSpace Lib "Kernel" (ByVal wFlags As Integer) As Long
  28. Declare Function GlobalCompact Lib "Kernel" (ByVal dwMinFree As Long) As Long
  29. Declare Function SystemHeapInfo Lib "toolhelp.dll" (shi As SYSHEAPINFO) As Integer
  30.  
  31. Sub ShowResources (L As Control)
  32.     'L is a Label control that will display the resource info
  33.  
  34.     Dim nl As String    'new line
  35.     Dim msg As String   'the text that will be displayed in the Label.Caption
  36.     
  37.     nl = Chr$(10)
  38.     ver = GetVersion()
  39.     ver_major$ = Format$(ver And &HFF)
  40.     ver_minor$ = Format$(ver \ &H100, "00")
  41.     msg = "Microsoft Windows version "
  42.     msg = msg + ver_major$ + "." + ver_minor$ + nl
  43.     
  44.     ' Get CPU type and operating mode
  45.     status& = GetWinFlags()
  46.     If status& And WF_CPU286 Then msg = msg + "286"
  47.     If status& And WF_CPU386 Then msg = msg + "386"
  48.     If status& And WF_CPU486 Then msg = msg + "386"     'even though its a 486, we are still in 386 enhanced mode
  49.     If status& And WF_STANDARD Then msg = msg + " Standard Mode" + nl
  50.     If status& And WF_ENHANCED Then msg = msg + " Enhanced Mode" + nl
  51.     
  52.     If status& And WF_80x87 Then
  53.         msg = msg + "Math Co-processor   Present"
  54.     Else
  55.         msg = msg + "Math Co-processor   none"
  56.     End If
  57.     msg = msg + nl
  58.     
  59.     ' Get free memory
  60.     memory& = GetFreeSpace(0)
  61.     msg = msg + "Memory: "
  62.     msg = msg + Format$(memory& \ 1024, "###,###,###") + "K" + nl
  63.     
  64.     ' The follow lines take a long time to execute.
  65.     'memory& = GlobalCompact(&HFFFFFFFF)
  66.     'msg = msg + "Largest free block: "
  67.     'msg = msg + Format$(memory& \ 1024, "###,###,###") + "K" + nl
  68.     
  69.     ' Get free system resources
  70.     ' The API SystemHeapInfo became available in Windows version 3.1
  71.     If ver >= &H310 Then
  72.         Dim shi As SYSHEAPINFO
  73.         shi.dwSize = Len(shi)
  74.         If SystemHeapInfo(shi) Then
  75.             msg = msg + "User:" + Format$(shi.wUserFreePercent) + "" + Space$(9) + "GDI:" + Format$(shi.wGDIFreePercent) + ""
  76.         End If
  77.     End If
  78.     L.Caption = msg
  79.  
  80. End Sub
  81.  
  82.